package StackAndQueue;

import java.util.Stack;

class MyQueue {
    Stack<Integer> stack;
    Stack<Integer> temp;
    public MyQueue() {
        stack = new Stack<>();
        temp = new Stack<>();
    }
    
    public void push(int x) {
        stack.push(x);
    }
    
    public int pop() {
        exc();
        return temp.pop();
    }
    
    public int peek() {
        exc();
        return temp.peek();
    }
    
    public boolean empty() {
        return temp.empty() && stack.empty();
    }
    public void exc(){
        if (!temp.empty()){
            return;
        }
        while (!stack.empty()){
            temp.push(stack.pop());
        }
    }
}